package com.eastfair.imaster.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 论坛主题嘉宾
 * </p>
 *
 * @author zjn
 * @date 2021-11-10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ConferenceTopicSpeakerTypeEnum", description = "类型 #{host:主持人;speaker:演讲者-枚举")
public enum ConferenceTopicSpeakerTypeEnum implements BaseEnum {

    /**
     * HOST="主持人"
     */
    HOST("主持人"),
    /**
     * SPEAKER="演讲者"
     */
    SPEAKER("演讲者"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ConferenceTopicSpeakerTypeEnum match(String val, ConferenceTopicSpeakerTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ConferenceTopicSpeakerTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ConferenceTopicSpeakerTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "HOST,SPEAKER", example = "HOST")
    public String getCode() {
        return this.name();
    }

}
